package com.doraemon.module.buyer.vo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * http返回值
 * Created by doraemon on 2017/9/12.
 */
@Data
@ApiModel(value = "ReturnValue")
public class ReturnVO {
    /**
     * 状态码
     */
    @ApiModelProperty(value = "状态码",required = true)
    private Integer code;
    /**
     * 描述
     */
    @ApiModelProperty(value = "处理说明",required = true)
    private String msg;

    /**
     * 返回数据
     */
    @ApiModelProperty(value = "响应数据",required = true)
    private Object data;

    public static ReturnVO success(Object data){
        ReturnVO returnVO = new ReturnVO();
        returnVO.setCode(0);
        returnVO.setMsg("请求成功");
        returnVO.setData(data);
        return  returnVO;
    }

    public static ReturnVO success(){
        ReturnVO returnVO = new ReturnVO();
        returnVO.setCode(0);
        returnVO.setMsg("请求成功");
        returnVO.setData(null);
        return  returnVO;
    }

    public static ReturnVO error(Integer code,String msg){
        ReturnVO returnVO = new ReturnVO();
        returnVO.setCode(code);
        returnVO.setMsg(msg);
        return  returnVO;
    }


}
